<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta charset="utf-8" />
	<title>aaaa</title>
</head>
<body>

<p>Send msg</p> 
<input id="input" value="i am msg from web/js" />  
<button id="send">call cpp-a1</button> 

<p>Recv msg</p> 
<textarea id="output" readonly="readonly" cols=80 rows=10></textarea><br /> 

        
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>  
<script type="text/javascript">  
function showmsg(message)  
{  
    var output = document.getElementById("output");  
    output.innerHTML = output.innerHTML + message + "\n";  
}  
//Web initial loading 
 window.onload = function() { 
	showmsg("I am from web, call js func!");   
    new QWebChannel(qt.webChannelTransport, function(channel) { 
    
        //Get Qt interact object  
        var a1 = channel.objects.a1; 
        
        //Web send message to Qt 
        document.getElementById("send").onclick = function() {  
            var input = document.getElementById("input");  
            if (!input.value) {  
                return;  
            }  
            
            //Web use the interface of Qt 
            a1.t1(input.value);                  
        }  
        
        //Web connect the Qt signal, then Qt can call "output" function
        a1.sigNotify.connect(function(str) {  
            showmsg(str);  
        });    
    });  
    }  

</script>  
</body>
</html>
